jQuery(function($) {
  $("#loginSubmit").click(
    function()
    {
        var request = $.ajax({
            url: "/admin/adminLogin/ajaxLogin",
            type: "POST",
            data: {
                username : $("#username").val(),
                password : $("#password").val(),
                verify_code : $("#verify_code").val()
            },
            dataType: "json"
        });
        request.done(function( result ) {
            if(result.status)
            {
                location.href = result.url;
            }
            else
            {
                alert( result.error_message);
            }
            reload_gd(document.getElementById('verify_code_img'), true);
        });
        request.fail(function( jqXHR, textStatus ) {
            alert( "登录失败，请稍候再试！");
        });
        return false;
    }
  );


  (function(){
      var login_remember = window.QuickCookie.getCookie("login_remember");
      var login_username = window.QuickCookie.getCookie("login_username");
      if( login_remember && login_username)
      {
          $("#username").val(login_username);
          document.getElementById("login_remember").checked = true;
      }
  })();
  $("#login_remember").click(
      function()
      {
          if(document.getElementById("login_remember").checked)
          {
              var username = $("#username").val();
              if(username)
              {
                  window.QuickCookie.setCookie("login_username", username);
                  window.QuickCookie.setCookie("login_remember", "1");
              }
          }
          else
          {
              window.QuickCookie.removeCookie("login_remember");
          }
      }
  );
});